<template>
  <ContentTopWidget ref="refTop"
                    :recent-targets="recentEntities" :click-return="onReturnPrevView"
                    :target-changed="onRealmChanged" :target-label="'最近领域：'"
                    :target-name="'领域：'" :target-holder="'请选择用户领域'"/>
</template>

<script setup lang="ts">

import {effect, ref, toRaw} from "vue";
import {useStore} from "@/stores";
import ContentTopWidget from "@/widget/ContentTopWidget.vue";

const store = useStore();
const refTop = ref();
const emits = defineEmits(['returnPrevView', 'entityDetail']);

defineProps<{
  recentLabel: string,
  entity: any,
  recentEntities: any
}>();

effect(() => {
  const pl: any = store.$state.realms;
  refTop.value?.updateCurrentTarget(pl);
})

const onRealmChanged = (realm: any) => {
  store.setCurrentRealm(toRaw(realm));
}

const onReturnPrevView = () => {
  emits('returnPrevView');
}

</script>

<style scoped>

</style>
